package com.zkingsoft.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zkingsoft.dao.NewAssessmentDao;
import com.zkingsoft.dao.TaskExecutionDao;
import com.zkingsoft.model.NewAssessment;
import com.zkingsoft.model.TaskExecution;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.services.NewAssessmentService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-12-07 11:38
 */
@Service("newAssessmentService")
public class  NewAssessmentServiceImpl implements    NewAssessmentService  {

	
	@Autowired
	private NewAssessmentDao newAssessmentDao;
	@Autowired
	private TaskExecutionDao taskExecutionDao;
	
	
	@Override
	public int add(NewAssessment newAssessment){
		
		return newAssessmentDao.insert(newAssessment);
		
	}
   	
    @Override
	public int modify(NewAssessment newAssessment){
	
		return newAssessmentDao.update(newAssessment);
	
	}
	
	@Override
	public int remove(List<Long> list){
	
		return newAssessmentDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long id){
	
		return newAssessmentDao.deleteById(id);
	
	}
	
	@Override
	public int removeByModel(NewAssessment newAssessment){
	
		return newAssessmentDao.deleteByModel(newAssessment);
	
	}
	
	
	@Override
	public List<NewAssessment> findInPage(NewAssessment newAssessment,  PaginationVO pageVo){
	
		return newAssessmentDao.selectInPage(newAssessment , pageVo);
	
	}
	
	@Override
	public List<NewAssessment> findByModel(NewAssessment newAssessment){
	
		return newAssessmentDao.selectByModel(newAssessment);
	
	}
	
	@Override
	public int  findTotal(NewAssessment newAssessment){
	
		return newAssessmentDao.selectTotalRecord(newAssessment);
	
	}
	
	@Override
	public NewAssessment  findById(Long id){
	
		return newAssessmentDao.selectById(id);
	
	}
	/**
	 * 绑定导师
	 */
	@Override
	@Transactional
	public int binding(NewAssessment newAssessment) {
		TaskExecution taskExecution = new TaskExecution();
		taskExecution.setTaskName("绑定导师");
		taskExecution.setNewId(newAssessment.getNewId());
		taskExecution.setStatus("2");
		taskExecutionDao.insert(taskExecution);
		return newAssessmentDao.update(newAssessment);
	}

   	
	
	
}